//
// BonusPart.cpp for nibbler in /home/lefebv_w//workspace/cpp/nibbler/googleCode
// 
// Made by damien lefebvre
// Login   <lefebv_w@epitech.net>
// 
// Started on  Mon Mar 18 11:53:26 2013 damien lefebvre
// Last update Sun Mar 24 19:00:33 2013 damien lefebvre
//

#include	"BonusPart.hh"

BonusPart::BonusPart(void)
  : m_type(IGraphicLibrary::BONUS), m_pos_x(0), m_pos_y(0), m_img(IGraphicLibrary::IMG_BONUSPART)
{}

void		BonusPart::generatePosition(t_frame frame, std::vector< std::vector<Case *> > const & map, Snake const & snake)
{
  unsigned int	new_pos_x;
  unsigned int	new_pos_y;

  do
    {
      new_pos_x = random() % map.size();
      new_pos_y = random() % map[new_pos_x].size();
    } while (map[new_pos_x][new_pos_y]->getType() != IGraphicLibrary::EMPTY ||
	     snake.checkIntersection(new_pos_x, new_pos_y) == true);
  m_pos_x = new_pos_x;
  m_pos_y = new_pos_y;
}

void		BonusPart::draw(t_frame frame, IGraphicLibrary & graph) const
{
  graph.draw(m_pos_x, m_pos_y, m_img);
}

bool		BonusPart::checkSnakePosition(t_frame frame, Snake const & snake) const
{
  if (snake.getPosX() == m_pos_x && snake.getPosY() == m_pos_y)
    return (true);
  return (false);
}

void		BonusPart::move(t_frame frame, std::vector< std::vector<Case *> > const & map, Snake const & snake)
{
  (void)(map);
  (void)(snake);
  (void)(frame);
}
t_frame		BonusPart::getLastMove(void) const
{
  return (0);
}

t_frame		BonusPart::getFrameRate(void) const
{
  return (0);
}
